home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / August 96 / Workaround for PropagateEvents < prev   
Encoding:
Internet Message Format  |  1996-08-16  |  1.7 KB  |  [TEXT/ttxt]

  1. Subject:     Workaround for PropagateEvents problem
  2. Sent:        8/16/96 2:12 PM
  3. Received:    8/16/96 2:41 PM
  4. From:        Rob Cope, rob@eclipse.cpcn.com
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8.  
  9. For anyone that is interested, I have worked out a possible solution to the refCounting problems you encounter if you call SetPropagateEvents(true) on one of your embedded frames.  The problem is that if you set an embedded frame to propagate events, the containing Frame's refCount will be decrement every time an event associated with a facet (like a mouse event) is propagated, which eventually leads to a crash.  Until a fix is available in OpenDoc, you can put the following logic inside your part's HandleEvent method:
  10.  
  11.     if ((eventInfo != NULL) && (eventInfo->propagated == kODTrue) && (odFacet != NULL))
  12.         odFrame->Acquire(ev);
  13.  
  14. Note that when the problem is fixed in OpenDoc, this fix will cause your frame to have too many refs, so it will not get flushed from memory.  However, if you need propagated events, too many refs are better than too few.
  15.  
  16. If you are using ODF it is a little more complicated.  You need to create your own subclass of FW_CEventDispatcher, put the above code in an override of the Dispatch method (as well as a call to the parent's Dispatch), and then override PrivNewEventDispatcher in your FW_CPart subclass to install your dispatcher.
  17.  
  18. I have been testing this for a while and it looks good, but I suggest doing your own tests too.  Let me know if anyone finds any problems with this.  
  19.  
  20. Thanks again to Christopher Linn for helping us work this out.
  21.  
  22. Rob Cope
  23. Eclipse Services
  24.